home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / CMPLTPAS / POLYGONS.PAS < prev    next >
Pascal/Delphi Source File  |  1988-09-02  |  2KB  |  71 lines

  1. {--------------------------------------------------------------}
  2. {                         Polygons                             }
  3. {                                                              }
  4. {      Polygon draw/polygon fill demonstration program         }
  5. {                                                              }
  6. {                             by Jeff Duntemann                }
  7. {                             Turbo Pascal V5.0                }
  8. {                             Last update 9/3/88               }
  9. {                                                              }
  10. {     From: COMPLETE TURBO PASCAL 5.0  by Jeff Duntemann       }
  11. {    Scott, Foresman & Co., Inc. 1988   ISBN 0-673-38355-5     }
  12. {--------------------------------------------------------------}
  13.  
  14. PROGRAM Polygons;
  15.  
  16. USES Graph;
  17.  
  18. CONST
  19.   Squiggles : FillPatternType =
  20.               ($94,$84,$48,$30,$00,$c1,$22,$14);
  21.  
  22.   Pentagon  : ARRAY[0..5] OF PointType =
  23.               ((X : 100; Y :  10),
  24.                (X : 200; Y :  80),
  25.                (X : 155; Y : 160),
  26.                (X :  45; Y : 160),
  27.                (X :   0; Y :  80),
  28.                (X : 100; Y :  10));
  29.  
  30.   BigDipper : ARRAY[0..5] OF PointType =
  31.               ((X : 350; Y :  20),
  32.                (X : 420; Y :  35),
  33.                (X : 475; Y : 100),
  34.                (X : 450; Y : 160),
  35.                (X : 530; Y : 195),
  36.                (X : 600; Y : 150));
  37.  
  38.  
  39. VAR
  40.   I           : Integer;
  41.   GraphDriver : Integer;
  42.   GraphMode   : Integer;
  43.   ErrorCode   : Integer;
  44.  
  45.  
  46. BEGIN
  47.   GraphDriver := Detect;  { Let the BGI determine what board we're using }
  48.   DetectGraph(GraphDriver,GraphMode);
  49.   InitGraph(GraphDriver,GraphMode,'');
  50.   IF GraphResult <> 0 THEN
  51.     BEGIN
  52.       Writeln('>>Halted on graphics error: ',GraphErrorMsg(GraphResult));
  53.       Halt(2)
  54.     END;
  55.  
  56.   SetFillPattern(Squiggles,White);
  57.  
  58.   DrawPoly(6,Pentagon);
  59.   FOR I := 0 TO 5 DO     { Translate the pentagon down 160 pixels }
  60.     Pentagon[I].Y := Pentagon[I].Y + 160;
  61.   FillPoly(6,Pentagon);
  62.  
  63.   DrawPoly(6,BigDipper);
  64.   FOR I := 0 TO 5 DO     { Translate the Big Dipper down 140 pixels }
  65.     BigDipper[I].Y := BigDipper[I].Y + 140;
  66.   FillPoly(6,BigDipper);
  67.  
  68.   Readln;
  69.   CloseGraph;
  70. END.
  71.